//
//  HomeOwnViewModel.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/3.
//

import Foundation
import SwiftUI
class AiCustom2ViewModel : BaseViewModel {
    
    @Published var items = [AiCustomBean]()
    @Published var status = ""
    @Published var status2 = ""

    
    func getData(_ isRefresh: Bool = false) {
        items.removeAll()
        requestList(isRefresh: isRefresh) {
            let dao = AiCustomDao()
            let list = try await dao.getList()
            try check(!isRefresh || !list.isEmpty, "暂无API连接")
            return list
        } suc: { list in
            self.items.append(contentsOf: list)
            self.status = ""
            self.status2 = ""
        } fail: {
            self.status = $0.message
            self.status2 = "接入自定义API，享有更高级的AI模型"
        }
    }
    
    deinit {
        AiCustomUtils.shared.doCustomAi()
    }
    
}
